package com.zzy.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class DayUtil {
	
	public static final String PATTERN_TIME = "HH:mm:ss";

	public static String getNowDay() {
		String day = DateUtil.format(new Date(), DateUtil.PATTERN_DATE);
		return day;
	}
	
	public static String getNowDateTime() {
		String day = DayUtil.getNowDay(DateUtil.PATTERN_DATETIME);
		return day;
	}
	
	public static String getNowTime() {
		String day = DayUtil.getNowDay(PATTERN_TIME);
		return day;
	}
	
	
	public static String getNowDay(String pattern) {
		String day = DateUtil.format(new Date(), pattern);
		return day;
	}

	
	
	
	/**
	 * day1在day2之后
	 * @param day1
	 * @param day2
	 * @return
	 */
	public static boolean after(String day1, String day2) {
		if(day1.equals(day2)) {
			return false;
		}
		Date date1 = DateUtil.parse(day1, DateUtil.PATTERN_DATE);
		Date date2 = DateUtil.parse(day2, DateUtil.PATTERN_DATE);
		boolean flag = date1.after(date2);
		return flag;
	}
	
	
	/**
	 * day1在day2之前
	 * @param day1
	 * @param day2
	 * @return
	 */
	public static boolean before(String day1, String day2) {
		if(day1.equals(day2)) {
			return false;
		}
		Date date1 = DateUtil.parse(day1, DateUtil.PATTERN_DATE);
		Date date2 = DateUtil.parse(day2, DateUtil.PATTERN_DATE);
		boolean flag = date1.before(date2);
		return flag;
	}
	
	
	
	
	public static String getAmPm() {
		Date date = new Date();
		SimpleDateFormat dateFormat2 = new SimpleDateFormat("aa", Locale.ENGLISH);
		String amPm = dateFormat2.format(date);
		return amPm;
	}	
	
	
	public static Integer getHour() {
		Date date = new Date();
		Integer hour = DateUtil.getHour(date);
		return hour;
	}
	

	
	public static String getNextDay(List<String> dayList, String currentDay) {
		for(int i =0 ; i<dayList.size(); i++) {
			String day = dayList.get(i);
			if(currentDay.equals(day)) {
				return dayList.get(i+1);
			}
		}
		return dayList.get(0);
	}
	
	
	public static void main(String[] args) {
		System.out.println(DayUtil.getNowTime());
	}

}
